#include <cstdio>

bool visit[ 9 ];
int s[ 9 ], f[ 9 ][ 9 ][ 9 ], jc[ 10 ] = { 1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880 } ;

void dfs( int step )
{
    int i, j, k;
    int a, b, c;
    if ( step < 9 )
    {
        for ( i = 1; i <= 9; i++ )
            if ( !visit[ i ] )
            {
                visit[ i ] = true;
                s[ step ] = i;
                dfs( step + 1 );
                visit[ i ] = false;
            }
    }
    else
    {
        a = 0;
        for ( i = 0; i < 4; i++ )
        {
            a = a * 10 + s[ i ];
            b = 0;
            for ( j = i + 1; j <= i + 4; j++ )
            {
                b = b * 10 + s[ j ];
                c = 0;
                for ( k = j + 1; k < 9; k++ )
                {
                    c = c * 10 + s[ k ];
                    if ( a * b == c )
                        f[ i + 1 ][ j - i ][ k - j ]++;
                }
            }
        }
    }
}

int main( )
{
    int a, b, c;
    dfs( 0 );
    while ( scanf("%d%d%d", &a, &b, &c) )
    {
        if ( a == 0 && b == 0 && c == 0 )
            break;
        printf("%d\n", f[ a ][ b ][ c ] / jc[ 9 - a - b - c ]);
    }
    return 0;
}
